package com.zlb.app.modules.quartz.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zlb.app.common.entity.R;
import com.zlb.app.modules.quartz.entity.JobLog;
import com.zlb.app.modules.quartz.service.IJobLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.Collections;

/**
 * 定时任务调度日志表 控制层
 * @Author zWX1367238
 * @Date 2024-08-27 11:57:56
 */
@RestController
@RequestMapping("/job/log")
@RequiredArgsConstructor
@Api(tags = "定时任务调度日志表")
public class JobLogController {

    private final IJobLogService jobLogService;

    @PostMapping
    @ApiOperation("保存定时任务调度日志表")
    public R<Boolean> save(@RequestBody JobLog jobLog) {
        return R.ok(this.jobLogService.saveOrUpdate(jobLog));
    }

    @GetMapping("/{id}")
    @ApiOperation("根据id查询定时任务调度日志表")
    public R<JobLog> getById(@PathVariable("id") Long id) {
        return R.ok(this.jobLogService.getById(id));
    }

    @GetMapping("/page")
    @ApiOperation("分页查询定时任务调度日志表数据")
    public R<IPage<JobLog>> page(Long id) {
        return R.ok(this.jobLogService.pages(id));
    }

    @DeleteMapping("/{ids}")
    @ApiOperation("根据id集合删除定时任务调度日志表")
    public R<Boolean> deleteByIds(@PathVariable("ids") Long[] ids) {
        return R.ok(this.jobLogService.removeByIds(Collections.singletonList(ids)));
    }

}
